package com.asj.house.controller;

import com.asj.house.client.HouseRoomMapClient;
import com.asj.house.domain.HouseRoomDetail;
import com.asj.house.domain.HouseRoomMap;
import com.asj.house.returns.RespEntity;
import com.asj.house.returns.RespTable;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 房源地图信息管理 前端控制器
 * </p>
 *
 * @author asj
 * @since 2021-02-03
 */
@RestController
@RequestMapping("/house-room-map")
@Slf4j
@Api(value = "房源地图信息相关接口", tags = "房源地图信息相关接口")
public class HouseRoomMapController {

    @Resource
    private HouseRoomMapClient houseRoomMapClient;

    @ApiOperation(value = "房源地图信息列表")
    @GetMapping("/list")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "page", value = "当前页数", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "limit", value = "每页数量", required = true)
    })
    public RespTable listHouseRoomMap(@RequestParam(value = "page", required = true) Integer page,
                                      @RequestParam(value = "limit", required = true) Integer limit) {
        RespTable respTable = houseRoomMapClient.listHouseRoomMap(page, limit);
        return respTable;
    }

    @GetMapping("/search")
    @ApiOperation(value = "搜索房源地图信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "page", value = "当前页数", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "limit", value = "每页数量", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "String", name = "name", value = "小区名称", required = true)
    })
    public RespTable searchHouseRoomMap(@RequestParam(value = "page", required = true) Integer page,
                                           @RequestParam(value = "limit", required = true) Integer limit,
                                           @RequestParam(value = "name", required = true) String name) {
        RespTable respTable = houseRoomMapClient.searchHouseRoomMap(page, limit, name);
        return respTable;
    }

    @PutMapping("/update")
    @ApiOperation(value = "编辑房源地图信息")
    public RespEntity updateHouseRoomMap(HouseRoomMap houseRoomMap) {
        RespEntity respEntity = houseRoomMapClient.updateHouseRoomMap(houseRoomMap);
        return respEntity;
    }

}
